package logic

import (
	"api/model/mysql"
	"context"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewListInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListInfoLogic {
	return &ListInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ListInfoLogic) ListInfo(in *house.ListInfoRequest) (*house.ListInfoResponse, error) {
	// todo: add your logic here and delete this line

	var info mysql.HouseGoods

	mysql.DB.First(&info)

	return &house.ListInfoResponse{
		GoodsImg:    info.GoodsImg,
		GoodsAuthor: info.GoodsAuthor,
		GoodsArea:   info.GoodsArea,
		GoodsPrice:  float32(info.GoodsPrice),
		GoodsStatus: int64(info.GoodsStatus),
		Id:          int64(info.GoodsStatus),
	}, nil
}
